/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    height: 100vh;
    overflow: hidden;
}

/* Main container - responsive height */
.container {
    display: flex;
    height: 100vh;
    max-height: 450px; /* For iframe */
    padding: 8px;
    gap: 8px;
}

/* Detect if in new tab vs iframe */
@media (min-height: 500px) {
    .container {
        max-height: 90vh;
    }
}

/* Left panel for building selection */
.left-panel {
    width: 200px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
}

.buildings-section h3 {
    color: #1976d2;
    font-size: 16px;
    margin-bottom: 8px;
    text-align: center;
}

.building-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

/* Building items - draggable */
.building-item {
    background: #f8f9fa;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 8px;
    text-align: center;
    cursor: grab;
    transition: all 0.3s ease;
    min-height: 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.building-item:hover {
    background: #e3f2fd;
    border-color: #1976d2;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.building-item:active {
    cursor: grabbing;
    transform: scale(0.95);
}

.building-icon {
    font-size: 20px;
    line-height: 1;
}

.building-item span {
    font-size: 11px;
    font-weight: 500;
    color: #333;
}

/* Control buttons */
.controls-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: auto;
}

.control-btn {
    background: #1976d2;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    white-space: nowrap;
}

.control-btn:hover {
    background: #1565c0;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(25,118,210,0.3);
}

.reset-btn {
    background: #f44336;
}

.reset-btn:hover {
    background: #d32f2f;
}

/* Map container */
.map-container {
    flex: 1;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    position: relative;
    overflow: hidden;
    background-image: 
        linear-gradient(90deg, #e0e0e0 1px, transparent 1px),
        linear-gradient(180deg, #e0e0e0 1px, transparent 1px);
    background-size: 30px 30px;
}

/* Drop zones */
.drop-zone {
    position: absolute;
    border: 2px dashed #bdbdbd;
    border-radius: 8px;
    background: rgba(255,255,255,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    color: #666;
    transition: all 0.3s ease;
    min-height: 80px;
}

.drop-zone.residential {
    top: 20px;
    left: 20px;
    width: 120px;
    height: 80px;
    background: rgba(76, 175, 80, 0.1);
    border-color: #4caf50;
    color: #2e7d32;
}

.drop-zone.commercial {
    top: 20px;
    right: 20px;
    width: 120px;
    height: 80px;
    background: rgba(255, 152, 0, 0.1);
    border-color: #ff9800;
    color: #ef6c00;
}

.drop-zone.recreational {
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 120px;
    height: 80px;
    background: rgba(33, 150, 243, 0.1);
    border-color: #2196f3;
    color: #1565c0;
}

.drop-zone.drag-over {
    border-style: solid;
    background-opacity: 0.3;
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

/* Placed buildings */
.placed-building {
    position: absolute;
    background: white;
    border: 2px solid #1976d2;
    border-radius: 8px;
    padding: 8px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 60px;
    min-height: 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.placed-building:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.placed-building .building-icon {
    font-size: 24px;
}

.placed-building span {
    font-size: 10px;
    font-weight: 600;
    color: #333;
}

/* Results panel */
.results-panel {
    width: 180px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.results-panel h3 {
    color: #1976d2;
    font-size: 16px;
    text-align: center;
    margin-bottom: 8px;
}

/* Impact indicators */
.impact-indicators {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.indicator {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.indicator-label {
    font-size: 12px;
    font-weight: 600;
    color: #333;
}

.indicator-bar {
    height: 16px;
    background: #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
}

.indicator-fill {
    height: 100%;
    border-radius: 8px;
    transition: width 0.5s ease;
    position: relative;
}

.happiness-fill {
    background: linear-gradient(90deg, #4caf50, #8bc34a);
}

.accessibility-fill {
    background: linear-gradient(90deg, #2196f3, #03a9f4);
}

.safety-fill {
    background: linear-gradient(90deg, #ff9800, #ffc107);
}

.indicator-value {
    font-size: 11px;
    font-weight: 600;
    color: #666;
    text-align: center;
}

/* Feedback text */
.feedback-text {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 12px;
    font-size: 12px;
    line-height: 1.4;
    color: #333;
    text-align: center;
    border-left: 4px solid #1976d2;
    margin-top: auto;
}

/* Center tooltip */
.center-tooltip {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.9);
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    max-width: 300px;
    text-align: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.center-tooltip.show {
    opacity: 1;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .container {
        flex-direction: column;
        height: 100vh;
        max-height: none;
    }
    
    .left-panel {
        width: 100%;
        height: 120px;
        flex-direction: row;
        overflow-x: auto;
    }
    
    .buildings-section {
        flex: 1;
    }
    
    .building-grid {
        grid-template-columns: repeat(6, 1fr);
        gap: 4px;
    }
    
    .building-item {
        min-height: 50px;
        padding: 4px;
    }
    
    .building-icon {
        font-size: 16px;
    }
    
    .building-item span {
        font-size: 9px;
    }
    
    .controls-section {
        flex-direction: row;
        gap: 8px;
        margin-top: 0;
        margin-left: 12px;
    }
    
    .results-panel {
        width: 100%;
        height: 100px;
        flex-direction: row;
        align-items: center;
    }
    
    .impact-indicators {
        flex-direction: row;
        flex: 1;
        gap: 8px;
    }
    
    .drop-zone {
        font-size: 10px;
        min-height: 60px;
    }
}

/* Touch targets for mobile */
@media (pointer: coarse) {
    .building-item,
    .control-btn,
    .placed-building {
        min-height: 44px;
        min-width: 44px;
    }
}